﻿<?php 
require("resize.php"); 
require("updateProfile.php");
	header("Content-Type: text/html;charset=utf-8");
	
	$uploadDir="tempImages/";
	$name =$_FILES['archivo']['name'];
	error_log($name);
	$uploadFile = $uploadDir.corregirNombre($name);
	$isUploaded = move_uploaded_file($_FILES['archivo']['tmp_name'], $uploadFile);
	//echo("<img src='files/".$name."'/>");
	//$_SESSION['id']=6;
	
	$nuevoName=corregirNombre($name);
	$guardarAvatarBD=new UpdateProfile();
	$valor=$guardarAvatarBD->getId($_SESSION['id']);
	$guardarAvatarBD->avatar(corregirNombre($name),$valor);
	
	
	$im=new Resize();
	$src=$im->achicar($uploadFile, corregirNombre($name));
		//echo("<img src='".$src."'/>");
	
	function corregirNombre($strName){
		$arrCaracteres1 = array("á", "é", "í", "ó", "ú", "Á", "É", "Í", "Ó", "Ú", "ñ", "Ñ");
		$arrCaracteres2 = array("a", "e", "i", "o", "u", "A", "E", "I", "O", "U", "n", "N");
		$strName = str_replace($arrCaracteres1, $arrCaracteres2, $strName);
		return $strName;
	} 

 ?>
